import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import sys
import math
import csv



#===========================================================

AsCores = [  (0.0 , 0.5 , 0.0)
            ,(0.0 , 0.5 , 0.5)
            ,(0.0 , 0.0 , 1.0)
            ,(0.5 , 0.5 , 0.0)
            ,(1.0 , 0.0 , 0.0)
           ]



#===========================================================

def improve_legend(ax=None):
    if ax is None:
        ax = plt.gca()

    for spine in ax.spines:
        ax.spines[spine].set_visible(False)
        
    k = -1
    for line in ax.lines:
        k = k + 1
        data_x, data_y = line.get_data()
        if 0 < (len(data_x)-1):
            right_most_x = data_x[len(data_x)-1]
            right_most_y = data_y[len(data_y)-1]
            ax.annotate(nomes[k], xy=(1, right_most_y), xytext=(6,0), color=line.get_color(), 
                xycoords = ax.get_yaxis_transform(), textcoords="offset points",
                size=14, va="center")

    ax.legend().set_visible(False)


#===========================================================



fields = ['Day','Total']

43
52
53
54
63


df1 = pd.read_csv('m43.csv', usecols=fields)
df2 = pd.read_csv('m54.csv', usecols=fields)
df3 = pd.read_csv('m53.csv', usecols=fields)
df4 = pd.read_csv('m52.csv', usecols=fields)
df5 = pd.read_csv('m63.csv', usecols=fields)

df1['cor']=0
df2['cor']=1
df3['cor']=2
df4['cor']=3
df5['cor']=4


nomes = ['3-4', '4-5' ,'3-5','2-5','3-6']
frames = [df1, df2, df3, df4, df5]



result = pd.concat(frames)



#===========================================================



#sns.set(style="darkgrid")
#sns.set(style="whitegrid")
#sns.set(palette="bright")
#sns.color_palette("hls", 7)





ax = sns.lineplot(x="Day", y="Total"
                  , hue="cor"
                  , palette=AsCores
                  , data=result)


improve_legend()

ax.set_title('Effect of Infection Window', fontsize=18);

ax.set_xlabel("Day",fontsize=16)
ax.set_ylabel("Total Infected",color="black",fontsize=16)
ax.tick_params(axis='x', labelsize=16)
ax.tick_params(axis='y', labelsize=16)

plt.grid()

plt.subplots_adjust(
top=0.88,
bottom=0.135,
left=0.125,
right=0.9,
hspace=0.2,
wspace=0.2
)

plt.draw()


plt.savefig('Figure-10b.eps', format='eps')
plt.savefig('Figure-10b.png', dpi=400)

plt.show ()

